package o;

import android.animation.TimeInterpolator;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.os.Build.VERSION;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
import android.view.View;
import androidx.annotation.ColorInt;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.annotation.VisibleForTesting;
import androidx.core.view.ViewCompat;
import o.ah.g;

@RestrictTo({d.LIBRARY_GROUP})
public final class ary {
    private static final Paint ˋ = null;
    private static final boolean ˎ = (VERSION.SDK_INT < 18);
    private int ʻ = 16;
    private float ʻॱ;
    private final RectF ʼ;
    private Typeface ʼॱ;
    private int ʽ = 16;
    private Typeface ʽॱ;
    private Typeface ʾ;
    private CharSequence ʿ;
    private CharSequence ˈ;
    private Paint ˉ;
    private float ˊ;
    private boolean ˊˊ;
    private float ˊˋ;
    private ColorStateList ˊॱ;
    private boolean ˊᐝ;
    private Bitmap ˋˊ;
    private boolean ˋˋ;
    private float ˋॱ;
    private float ˋᐝ;
    private int[] ˌ;
    private float ˍ;
    private float ˎˎ;
    private TimeInterpolator ˎˏ;
    private boolean ˏ;
    private final TextPaint ˏˎ;
    private final TextPaint ˏˏ;
    private float ˏॱ = 15.0f;
    private TimeInterpolator ˑ;
    private float ͺ = 15.0f;
    private float ͺॱ;
    private int ـ;
    private final View ॱ;
    private float ॱʻ;
    private float ॱʼ;
    private float ॱʽ;
    private ColorStateList ॱˊ;
    private float ॱˋ;
    private float ॱˎ;
    private float ॱͺ;
    private final Rect ॱॱ;
    private float ॱᐝ;
    private final Rect ᐝ;
    private float ᐝˊ;
    private float ᐝॱ;
    private int ᐧ;

    static {
        if (ˋ != null) {
            ˋ.setAntiAlias(true);
            ˋ.setColor(-65281);
        }
    }

    public ary(View view) {
        this.ॱ = view;
        this.ˏˎ = new TextPaint(129);
        this.ˏˏ = new TextPaint(this.ˏˎ);
        this.ॱॱ = new Rect();
        this.ᐝ = new Rect();
        this.ʼ = new RectF();
    }

    public void ˋ(TimeInterpolator timeInterpolator) {
        this.ˎˏ = timeInterpolator;
        ॱॱ();
    }

    public void ˊ(TimeInterpolator timeInterpolator) {
        this.ˑ = timeInterpolator;
        ॱॱ();
    }

    public void ˋ(float f) {
        if (this.ͺ != f) {
            this.ͺ = f;
            ॱॱ();
        }
    }

    public void ˊ(ColorStateList colorStateList) {
        if (this.ॱˊ != colorStateList) {
            this.ॱˊ = colorStateList;
            ॱॱ();
        }
    }

    public void ˋ(ColorStateList colorStateList) {
        if (this.ˊॱ != colorStateList) {
            this.ˊॱ = colorStateList;
            ॱॱ();
        }
    }

    public void ॱ(int i, int i2, int i3, int i4) {
        if (!ˊ(this.ᐝ, i, i2, i3, i4)) {
            this.ᐝ.set(i, i2, i3, i4);
            this.ˋˋ = true;
            ˋ();
        }
    }

    public void ˎ(int i, int i2, int i3, int i4) {
        if (!ˊ(this.ॱॱ, i, i2, i3, i4)) {
            this.ॱॱ.set(i, i2, i3, i4);
            this.ˋˋ = true;
            ˋ();
        }
    }

    public float ˏ() {
        if (this.ʿ == null) {
            return 0.0f;
        }
        ˋ(this.ˏˏ);
        return this.ˏˏ.measureText(this.ʿ, 0, this.ʿ.length());
    }

    public float ˎ() {
        ˋ(this.ˏˏ);
        return -this.ˏˏ.ascent();
    }

    public void ॱ(RectF rectF) {
        float ˏ;
        boolean ˏ2 = ˏ(this.ʿ);
        if (ˏ2) {
            ˏ = ((float) this.ॱॱ.right) - ˏ();
        } else {
            ˏ = (float) this.ॱॱ.left;
        }
        rectF.left = ˏ;
        rectF.top = (float) this.ॱॱ.top;
        rectF.right = !ˏ2 ? rectF.left + ˏ() : (float) this.ॱॱ.right;
        rectF.bottom = ((float) this.ॱॱ.top) + ˎ();
    }

    private void ˋ(TextPaint textPaint) {
        textPaint.setTextSize(this.ˏॱ);
        textPaint.setTypeface(this.ʾ);
    }

    void ˋ() {
        boolean z = this.ॱॱ.width() > 0 && this.ॱॱ.height() > 0 && this.ᐝ.width() > 0 && this.ᐝ.height() > 0;
        this.ˏ = z;
    }

    public void ˎ(int i) {
        if (this.ʽ != i) {
            this.ʽ = i;
            ॱॱ();
        }
    }

    public void ॱ(int i) {
        if (this.ʻ != i) {
            this.ʻ = i;
            ॱॱ();
        }
    }

    public void ˊ(int i) {
        cw ˊ = cw.ˊ(this.ॱ.getContext(), i, g.ۥ);
        if (ˊ.ᐝ(g.ॱߴ)) {
            this.ॱˊ = ˊ.ॱ(g.ॱߴ);
        }
        if (ˊ.ᐝ(g.ॱʹ)) {
            this.ˏॱ = (float) ˊ.ˎ(g.ॱʹ, (int) this.ˏॱ);
        }
        this.ـ = ˊ.ॱ(g.ॱᴵ, 0);
        this.ॱʻ = ˊ.ॱ(g.ॱᵎ, 0.0f);
        this.ॱʼ = ˊ.ॱ(g.ॱᵔ, 0.0f);
        this.ͺॱ = ˊ.ॱ(g.ॱߵ, 0.0f);
        ˊ.ॱ();
        if (VERSION.SDK_INT >= 16) {
            this.ʾ = ˏ(i);
        }
        ॱॱ();
    }

    public void ˋ(int i) {
        cw ˊ = cw.ˊ(this.ॱ.getContext(), i, g.ۥ);
        if (ˊ.ᐝ(g.ॱߴ)) {
            this.ˊॱ = ˊ.ॱ(g.ॱߴ);
        }
        if (ˊ.ᐝ(g.ॱʹ)) {
            this.ͺ = (float) ˊ.ˎ(g.ॱʹ, (int) this.ͺ);
        }
        this.ᐧ = ˊ.ॱ(g.ॱᴵ, 0);
        this.ॱʽ = ˊ.ॱ(g.ॱᵎ, 0.0f);
        this.ᐝˊ = ˊ.ॱ(g.ॱᵔ, 0.0f);
        this.ॱͺ = ˊ.ॱ(g.ॱߵ, 0.0f);
        ˊ.ॱ();
        if (VERSION.SDK_INT >= 16) {
            this.ʽॱ = ˏ(i);
        }
        ॱॱ();
    }

    private Typeface ˏ(int i) {
        TypedArray obtainStyledAttributes = this.ॱ.getContext().obtainStyledAttributes(i, new int[]{16843692});
        try {
            String string = obtainStyledAttributes.getString(0);
            if (string != null) {
                Typeface create = Typeface.create(string, 0);
                return create;
            }
            obtainStyledAttributes.recycle();
            return null;
        } finally {
            obtainStyledAttributes.recycle();
        }
    }

    public void ॱ(Typeface typeface) {
        if (this.ʾ != typeface) {
            this.ʾ = typeface;
            ॱॱ();
        }
    }

    public void ˏ(Typeface typeface) {
        if (this.ʽॱ != typeface) {
            this.ʽॱ = typeface;
            ॱॱ();
        }
    }

    public void ˎ(Typeface typeface) {
        this.ʽॱ = typeface;
        this.ʾ = typeface;
        ॱॱ();
    }

    public void ˏ(float f) {
        float ˋ = gr.ˋ(f, 0.0f, 1.0f);
        if (ˋ != this.ˊ) {
            this.ˊ = ˋ;
            ʻ();
        }
    }

    public final boolean ˋ(int[] iArr) {
        this.ˌ = iArr;
        if (!ॱ()) {
            return false;
        }
        ॱॱ();
        return true;
    }

    public final boolean ॱ() {
        return (this.ॱˊ != null && this.ॱˊ.isStateful()) || (this.ˊॱ != null && this.ˊॱ.isStateful());
    }

    public float ˊ() {
        return this.ˊ;
    }

    private void ʻ() {
        ˎ(this.ˊ);
    }

    private void ˎ(float f) {
        ˊ(f);
        this.ᐝॱ = ॱ(this.ॱˎ, this.ॱˋ, f, this.ˑ);
        this.ʻॱ = ॱ(this.ˋॱ, this.ॱᐝ, f, this.ˑ);
        ॱ(ॱ(this.ͺ, this.ˏॱ, f, this.ˎˏ));
        if (this.ॱˊ != this.ˊॱ) {
            this.ˏˎ.setColor(ˋ(ͺ(), ʽ(), f));
        } else {
            this.ˏˎ.setColor(ʽ());
        }
        this.ˏˎ.setShadowLayer(ॱ(this.ॱͺ, this.ͺॱ, f, null), ॱ(this.ॱʽ, this.ॱʻ, f, null), ॱ(this.ᐝˊ, this.ॱʼ, f, null), ˋ(this.ᐧ, this.ـ, f));
        ViewCompat.ˎ(this.ॱ);
    }

    @ColorInt
    private int ͺ() {
        if (this.ˌ != null) {
            return this.ˊॱ.getColorForState(this.ˌ, 0);
        }
        return this.ˊॱ.getDefaultColor();
    }

    @VisibleForTesting
    @ColorInt
    public int ʽ() {
        if (this.ˌ != null) {
            return this.ॱˊ.getColorForState(this.ˌ, 0);
        }
        return this.ॱˊ.getDefaultColor();
    }

    private void ॱˊ() {
        int i;
        float f = 0.0f;
        int i2 = 1;
        float f2 = this.ˋᐝ;
        ᐝ(this.ˏॱ);
        float measureText = this.ˈ != null ? this.ˏˎ.measureText(this.ˈ, 0, this.ˈ.length()) : 0.0f;
        int i3 = this.ʻ;
        if (this.ˊˊ) {
            i = 1;
        } else {
            i = 0;
        }
        i = hj.ˎ(i3, i);
        switch (i & 112) {
            case 48:
                this.ॱᐝ = ((float) this.ॱॱ.top) - this.ˏˎ.ascent();
                break;
            case 80:
                this.ॱᐝ = (float) this.ॱॱ.bottom;
                break;
            default:
                this.ॱᐝ = (((this.ˏˎ.descent() - this.ˏˎ.ascent()) / 2.0f) - this.ˏˎ.descent()) + ((float) this.ॱॱ.centerY());
                break;
        }
        switch (i & 8388615) {
            case 1:
                this.ॱˋ = ((float) this.ॱॱ.centerX()) - (measureText / 2.0f);
                break;
            case 5:
                this.ॱˋ = ((float) this.ॱॱ.right) - measureText;
                break;
            default:
                this.ॱˋ = (float) this.ॱॱ.left;
                break;
        }
        ᐝ(this.ͺ);
        if (this.ˈ != null) {
            f = this.ˏˎ.measureText(this.ˈ, 0, this.ˈ.length());
        }
        int i4 = this.ʽ;
        if (!this.ˊˊ) {
            i2 = 0;
        }
        i4 = hj.ˎ(i4, i2);
        switch (i4 & 112) {
            case 48:
                this.ˋॱ = ((float) this.ᐝ.top) - this.ˏˎ.ascent();
                break;
            case 80:
                this.ˋॱ = (float) this.ᐝ.bottom;
                break;
            default:
                this.ˋॱ = (((this.ˏˎ.descent() - this.ˏˎ.ascent()) / 2.0f) - this.ˏˎ.descent()) + ((float) this.ᐝ.centerY());
                break;
        }
        switch (i4 & 8388615) {
            case 1:
                this.ॱˎ = ((float) this.ᐝ.centerX()) - (f / 2.0f);
                break;
            case 5:
                this.ॱˎ = ((float) this.ᐝ.right) - f;
                break;
            default:
                this.ॱˎ = (float) this.ᐝ.left;
                break;
        }
        ˏॱ();
        ॱ(f2);
    }

    private void ˊ(float f) {
        this.ʼ.left = ॱ((float) this.ᐝ.left, (float) this.ॱॱ.left, f, this.ˑ);
        this.ʼ.top = ॱ(this.ˋॱ, this.ॱᐝ, f, this.ˑ);
        this.ʼ.right = ॱ((float) this.ᐝ.right, (float) this.ॱॱ.right, f, this.ˑ);
        this.ʼ.bottom = ॱ((float) this.ᐝ.bottom, (float) this.ॱॱ.bottom, f, this.ˑ);
    }

    public void ˊ(Canvas canvas) {
        int save = canvas.save();
        if (this.ˈ != null && this.ˏ) {
            float f;
            float f2 = this.ᐝॱ;
            float f3 = this.ʻॱ;
            int i = (!this.ˊᐝ || this.ˋˊ == null) ? 0 : 1;
            float f4;
            if (i != 0) {
                f = this.ˊˋ * this.ˍ;
                f4 = this.ˎˎ * this.ˍ;
            } else {
                f = this.ˏˎ.ascent() * this.ˍ;
                f4 = this.ˏˎ.descent() * this.ˍ;
            }
            if (i != 0) {
                f3 += f;
            }
            if (this.ˍ != 1.0f) {
                canvas.scale(this.ˍ, this.ˍ, f2, f3);
            }
            if (i != 0) {
                canvas.drawBitmap(this.ˋˊ, f2, f3, this.ˉ);
            } else {
                canvas.drawText(this.ˈ, 0, this.ˈ.length(), f2, f3, this.ˏˎ);
            }
        }
        canvas.restoreToCount(save);
    }

    private boolean ˏ(CharSequence charSequence) {
        int i = 1;
        if (ViewCompat.ʼ(this.ॱ) != 1) {
            i = 0;
        }
        return (i != 0 ? ha.ˊ : ha.ˏ).ॱ(charSequence, 0, charSequence.length());
    }

    private void ॱ(float f) {
        ᐝ(f);
        boolean z = ˎ && this.ˍ != 1.0f;
        this.ˊᐝ = z;
        if (this.ˊᐝ) {
            ˊॱ();
        }
        ViewCompat.ˎ(this.ॱ);
    }

    private void ᐝ(float f) {
        boolean z = true;
        if (this.ʿ != null) {
            float f2;
            boolean z2;
            float width = (float) this.ॱॱ.width();
            float width2 = (float) this.ᐝ.width();
            if (ˋ(f, this.ˏॱ)) {
                f2 = this.ˏॱ;
                this.ˍ = 1.0f;
                if (this.ʼॱ != this.ʾ) {
                    this.ʼॱ = this.ʾ;
                    z2 = true;
                } else {
                    z2 = false;
                }
            } else {
                f2 = this.ͺ;
                if (this.ʼॱ != this.ʽॱ) {
                    this.ʼॱ = this.ʽॱ;
                    z2 = true;
                } else {
                    z2 = false;
                }
                if (ˋ(f, this.ͺ)) {
                    this.ˍ = 1.0f;
                } else {
                    this.ˍ = f / this.ͺ;
                }
                float f3 = this.ˏॱ / this.ͺ;
                width = width2 * f3 > width ? Math.min(width / f3, width2) : width2;
            }
            if (width > 0.0f) {
                if (this.ˋᐝ != f2 || this.ˋˋ || r0) {
                    z2 = true;
                } else {
                    z2 = false;
                }
                this.ˋᐝ = f2;
                this.ˋˋ = false;
            }
            if (this.ˈ == null || r0) {
                this.ˏˎ.setTextSize(this.ˋᐝ);
                this.ˏˎ.setTypeface(this.ʼॱ);
                TextPaint textPaint = this.ˏˎ;
                if (this.ˍ == 1.0f) {
                    z = false;
                }
                textPaint.setLinearText(z);
                CharSequence ellipsize = TextUtils.ellipsize(this.ʿ, this.ˏˎ, width, TruncateAt.END);
                if (!TextUtils.equals(ellipsize, this.ˈ)) {
                    this.ˈ = ellipsize;
                    this.ˊˊ = ˏ(this.ˈ);
                }
            }
        }
    }

    private void ˊॱ() {
        if (this.ˋˊ == null && !this.ᐝ.isEmpty() && !TextUtils.isEmpty(this.ˈ)) {
            ˎ(0.0f);
            this.ˊˋ = this.ˏˎ.ascent();
            this.ˎˎ = this.ˏˎ.descent();
            int round = Math.round(this.ˏˎ.measureText(this.ˈ, 0, this.ˈ.length()));
            int round2 = Math.round(this.ˎˎ - this.ˊˋ);
            if (round > 0 && round2 > 0) {
                this.ˋˊ = Bitmap.createBitmap(round, round2, Config.ARGB_8888);
                new Canvas(this.ˋˊ).drawText(this.ˈ, 0, this.ˈ.length(), 0.0f, ((float) round2) - this.ˏˎ.descent(), this.ˏˎ);
                if (this.ˉ == null) {
                    this.ˉ = new Paint(3);
                }
            }
        }
    }

    public void ॱॱ() {
        if (this.ॱ.getHeight() > 0 && this.ॱ.getWidth() > 0) {
            ॱˊ();
            ʻ();
        }
    }

    public void ˋ(CharSequence charSequence) {
        if (charSequence == null || !charSequence.equals(this.ʿ)) {
            this.ʿ = charSequence;
            this.ˈ = null;
            ˏॱ();
            ॱॱ();
        }
    }

    public CharSequence ᐝ() {
        return this.ʿ;
    }

    private void ˏॱ() {
        if (this.ˋˊ != null) {
            this.ˋˊ.recycle();
            this.ˋˊ = null;
        }
    }

    private static boolean ˋ(float f, float f2) {
        return Math.abs(f - f2) < 0.001f;
    }

    public ColorStateList ʼ() {
        return this.ॱˊ;
    }

    private static int ˋ(int i, int i2, float f) {
        float f2 = 1.0f - f;
        return Color.argb((int) ((((float) Color.alpha(i)) * f2) + (((float) Color.alpha(i2)) * f)), (int) ((((float) Color.red(i)) * f2) + (((float) Color.red(i2)) * f)), (int) ((((float) Color.green(i)) * f2) + (((float) Color.green(i2)) * f)), (int) ((f2 * ((float) Color.blue(i))) + (((float) Color.blue(i2)) * f)));
    }

    private static float ॱ(float f, float f2, float f3, TimeInterpolator timeInterpolator) {
        if (timeInterpolator != null) {
            f3 = timeInterpolator.getInterpolation(f3);
        }
        return aqv.ˏ(f, f2, f3);
    }

    private static boolean ˊ(Rect rect, int i, int i2, int i3, int i4) {
        return rect.left == i && rect.top == i2 && rect.right == i3 && rect.bottom == i4;
    }
}
